<?php
namespace Common\Model;
use Common\Model\VRNewsModel;
class NewsSourceModel extends VRNewsModel
{
//查看 来源 如果存在获取来源ID 并保存，如果没有 则新添加一条来源并保存 来源ID
    public function GetId($source){
        $source_info = $this->where("name = '".$source."'")->field("source_id")->find();
        if($source_info){
            return $source_info['source_id'];
        }else{
            $data['name'] = $source;
            $data['create_time'] = date("Y-m-d H:i:s");
            $data['creator_id'] = $_SESSION['ADMIN_ID'];
            $add_res = $this->add($data);

            return $add_res;
        }
    }
}